package be.bonamis.umpire.ui.client;

import be.bonamis.umpire.ui.client.gin.UmpireGinjector;

import com.google.gwt.activity.shared.ActivityManager;
import com.google.gwt.core.client.EntryPoint;
import com.google.gwt.core.client.GWT;
import com.google.gwt.user.client.Command;
import com.google.gwt.user.client.ui.RootPanel;
import com.google.gwt.user.client.ui.SimplePanel;

public class Application implements EntryPoint {
	private static UmpireGinjector ginjector;
	private SimplePanel appWidget = new SimplePanel();

	/**
	 * This is the entry point method.
	 */
	public void onModuleLoad() {
		ginjector = GWT.create(UmpireGinjector.class);
		final ClientFactory clientFactory = ginjector.getClientFactory();

		AppActivityMapper mapper = new AppActivityMapper(clientFactory);

		ActivityManager manager = new ActivityManager(mapper, clientFactory.getEventBus());
		manager.setDisplay(appWidget);

		RootPanel.get().add(appWidget);

		clientFactory.getPlaceHistoryHandler().handleCurrentHistory();
	}

	public static UmpireGinjector getInjector() {
		return ginjector;
	}

	public void start(final ClientFactory clientFactory) {
		start(clientFactory, null);
	}

	public void start(final ClientFactory clientFactory, final Command postInitCommand) {

	}

}
